by Steve Henle Hazel John Jim Schlough
Funding the contemporary K-12 classroom is greatly challenging and many teachers believe that resources provided are insufficient in meeting the most basic objectives. Nontraditional support is playing an increasingly important part in supporting the modern classroom.
The Donors Choose web platform provides a mechanism of providing support to teachers by benefactors. A potential donor may read an appeal written by a teacher to fulfill a specific classroom material need, and donates towards their funding goal. If the funding goal is met, these materials are sourced by fulfillment sources under the control of the Donors Choose organization, and sent directly to the school.
Given the changes in public sentiments and commitments towards financial support of the community school over the past few decades, the ability to raise funds directly into the classroom might come to be considered a vital skill of the teacher in supporting classroom activities.
When written appeals succeed by becoming fully funded, or fail by expiring, the data surrounding the appeal is gathered and made publicly available. By analyzing this data, it might be possible to better understand the factors correlated with success or failure of a written appeal. Some factors such as location, date and time, and poverty level are beyond the control of a teacher. Other factors, such as the written content of an appeal, or to a lesser extent, the credentials of the teacher, can be controlled.
We wish to apply statistical analysis of the available data in an effort to go beyond axiomatic and aesthetic beliefs regarding what makes a more or less effective funding proposal.
We set forth to answer the following questions regarding the funding proposals for Donors Choose.
What makes the difference between a proposal that is funded and one that expires?
Which are the winning qualities?
Of the predicting qualities, are there any that are under the control of the writer?
Does the content of the written essay matter?
We are using the data made publicly available on the Donors Choose website. This publicly available comes in the form of downloadable csv files, ranging in size from megabytes to gigabytes. This data can be found at here.
The proposals are one element in the open data set published from the Donors Choose web site. An image of the schema showing the suggested recomposition is in Appendix B, below, and can also be found at Donors Choose.
back to top
Our first task was to download the data, clean it up and extract the data we needed. We decided to do the analysis with just the data from 2014, so the final task was the filter out unneeded data.
Our first plan was to use a combination of AWK and SED to do the necessary data cleanup, but time & date fields proved to be problematic. After an evening of steady efforts along those lines, a C++ data cleaning application was written as a stop gap measure. This C++ data cleaner provided a temporary means to separate the 2014 projects records from the csv file and get the rest of the team started with the data. The source code for the intermediate c++ application, was named rm_old and its source code can be found here in Appendix A.
back to top
During analysis of the data files retrieved from the Donor’s Choose website, we noticed that it contained string fields with special characters that caused errors when using the standard read utilities for comma delimited files. The first plan was to read files line by line and use “gsub” to removed unnecessary characters, but this turned out very slow. We then tried to run the UNIX utility “sed” within the “pipe” function, but the special characters like ctrl-M made that problematic. The final iteration still used “sed” by was run as a system call from R. Each file required slight variations in the search patterns so different
Our final data wrangling consisted of the following steps:
A simple function was written to upload the cleaned data from RDS files stored on disk. All data exploration and analysis was run on the uploaded data.
We began an exploration of the data to see what relationships might be discovered within it, to compare the completed and expired projects.
## [1] "Data is nowhere near normal, looks like logistic analysis of funded vs non-funded make much more sense."
## [1] "Will not look at different factors contained in the projects file to determine if they affect the likliehood of getting funded. There are techinically three outcomes for each request. Complete, means reached or succeeded funding goal. Expired, time ran out wihtout reaching goal. Reallocated, Did not reach goal, but donors chose to give previously pledge amount to a different proposal."
<<<<<<< HEAD
The first attempt to build a model was to use the glm method in the train function and select several variables from the earlier exploratory analysis that looked to have an effect. These variables included: amount of money asked for, school state, primary focus, primary subject, resource type, date posted. We used glm because our outcome is either funded or not funded and glm works well for logistic regression.
## Generalized Linear Model
##
## 170326 samples
## 45 predictor
##
## No pre-processing
## Resampling: Bootstrapped (25 reps)
## Summary of sample sizes: 170320, 170320, 170320, 170320, 170320, 170320, ...
## Resampling results:
##
## RMSE Rsquared
## 0.4396128 0.09132495
##
##
The RMSE from this method is not great, but it is a start so we tried to improve on it. First we filtered out some of the uncommon variables, that appeared to have an effect in the exploratory analysis. For example if the teacher was in teacher in teach for America, a New York teach fellow, was it a charter school, or other school types. All total these only filtered out few percent of the applications, and are factors the requesters can’t change so they are not useful in building a prediction model. We then ran the training again.
## Generalized Linear Model
##
## 133860 samples
## 45 predictor
##
## No pre-processing
## Resampling: Bootstrapped (25 reps)
## Summary of sample sizes: 133855, 133855, 133855, 133855, 133855, 133855, ...
## Resampling results:
##
## RMSE Rsquared
## 0.4428837 0.0920202
##
##
Removing these proposals did show an effect in an improvement of RMSE, even though it is . The next approach was that perhaps our model was trying to fit to many parameters, so we pared it down to only include the factors that the exploratory analysis showed to have the greatest effect. These factors were: cost, date of posting, and resource type.
## Generalized Linear Model
##
## 133860 samples
## 45 predictor
##
## No pre-processing
## Resampling: Bootstrapped (25 reps)
## Summary of sample sizes: 133860, 133860, 133860, 133860, 133860, 133860, ...
## Resampling results:
##
## RMSE Rsquared
## 0.4469327 0.07612293
##
##
This shows an even greater improvement in RMSE. In looking back at the data it was clear that the cost requested has the strongest effect. So we decided to run train again to see if that variable alone might improve our accurary (as shown by RMSE).
## Generalized Linear Model
##
## 133860 samples
## 45 predictor
##
## No pre-processing
## Resampling: Bootstrapped (25 reps)
## Summary of sample sizes: 133860, 133860, 133860, 133860, 133860, 133860, ...
## Resampling results:
##
## RMSE Rsquared
## 0.4478903 0.07179594
##
##
So using all the data, except the contents of the essay, provided by the requesters it appears that the best model we can build is using the total cost as a predictor.
As part of the data available from the DonorsChoose website, we were able to download the full text of the teacher-written requests accompanying all classroom projects. The heart of each teacher’s classroom project request is their written request, and we wanted to use text mining to see if we could extract information from the essays to predict which projects get funded. The two questions we chose to answer were:
Sentiment Analysis
We started by tokenizing the essay words and then using the sentiment lexicon from “nrc” to assign sentiments to the words. We then computed the percentage occurance for the sentiments in essays grouped by the funding status of the projects and compared.
We can see from the graph that both positive and negitive sentiments occur at an almost identical rate completed funded as well as expired projects. We can see the minor differences more clearly in the data frame.
## Source: local data frame [11 x 3]
##
## sentiment completed expired
## (chr) (dbl) (dbl)
## 1 anger 1.1026375 1.0838772
## 2 anticipation 5.6380648 5.5864252
## 3 disgust 0.4495098 0.4131162
## 4 fear 1.2389231 1.2130671
## 5 joy 5.9211053 5.7905396
## 6 negative 2.3453001 2.2955258
## 7 positive 17.0967005 17.3146193
## 8 sadness 1.4367613 1.3943689
## 9 surprise 2.0834330 2.0215808
## 10 trust 8.3226758 8.4123286
## 11 NA 54.3648887 54.4745512
Word Analysis
We then analyzed the occurance of specific words in the essays for insights. We started by looking at the top 10 words for both fully funded and expired projects.
The top 10 words for both categories were almost identical. The only thing that stood out a little was that “excited” was in the top ten for completed funded projects versus “technology” for expired projects. This could be related to the fact that technology is more expensive and thus there is a lower chance of the project getting fully funded.
We removed the common words for both project categories for the top 10 words to focus of the rest of the words.
We then used wordclouds to compare the words that occur the most in both funding categories. We started with high frequency words in essays for projects that were fully funded.
Then we compared it with the high frequency words in essays for projects that expired and weren’t fully funded.
Looking at the wordcloud, one of the things that stood out were the higher relative prominence of “books” for funded projects versus “technology” for expired projects.
| project_count_2014 | 170326 |
| completed_project_count_2014 | 118039 |
| completed_project_mean_word_count | 302 |
| completed_project_sd_word | 84 |
| expired_project_count_2014 | 51246 |
| expd_total_word_sums_count | 51245 |
| expd_total_word_sums_mean | 305 |
| expd_total_word_sums_sd | 86 |
Does essay word count matter?
Here we look at the number of words in essays, to see if there is any significant difference between the number of words in completed and expired essays.
## [1] "On average, completed essays had essay word counts that were 2.9918 shorter than expired ones"
The length of essay, in terms of word count, does not seem to matter much all by itself.
After examining the data, we were able to draw some conclusions. Of all of the predictors, the total project cost was found to the be most significant.
The original source code of the stop gap c++ data cleaning application is below.
####c++ Source code for rm_old
//
// main.cpp
// rm_old
//
// Created by Jim Schlough on 4/22/16.
// Copyright © 2016 Jim Schlough. All rights reserved.
//
#include <iostream>
#include <fstream> // for ifstream, ofstream
#include <string>
#include <ctime>
#include <cstdlib>
#include <stdio.h> // for tmpnam, remove
// for time & date processing:
#include <sstream>
#include <locale>
#include <iomanip>
using namespace std;
int main(int argc, const char * argv[]) {
// insert code here...
if (argc< 3 )
{
std::cout << "Usage rm_old fileInName bottomCutOffDate topCutOffDate dateFieldIndex" << endl;
std::cout << endl;
std::cout << " dateFieldIndex is ONE based" << endl;
}
char filebuf [L_tmpnam];
::strcpy(filebuf, argv[1]);
std::string outFileName;
int dateFieldIdx = 0;
dateFieldIdx = std::atoi(argv[4])-2;
// TODO: check for clean cutOffDateInput here
int64_t bottomCutOffDateValue = 0L, topCutOffDateValue = 0L;
bottomCutOffDateValue = std::atol(argv[2]);
topCutOffDateValue = std::atol(argv[3]);
// TODO: check for valid (positive integer) date field index (1 based) here
std::ifstream inputFile (filebuf, std::ios::in);
outFileName.append(filebuf);
outFileName.erase( outFileName.find(".csv"),4);
outFileName.append("_output.csv");
std::ofstream outputFile (outFileName, std::ios::out);
std::string line, submittedDateTimeStr, submittedDateStr;
bool skipFirst = true;
if (inputFile.is_open())
{
std::getline(inputFile, line);
skipFirst = (line.find('\"') == std::string::npos); // first line is header
while( inputFile)
{
if (skipFirst)
{
skipFirst = false;
outputFile << line << endl;
}
else std::getline(inputFile, line);
if (line.length() < 2) continue;
size_t numberCommas = std::count(line.begin(), line.end(), ',');
if (numberCommas < 43 ||
line.find("\"") == std::string::npos ) // skip the header line, which has no "
continue;
// find the position of the date in the 41st field
int x = 0;
//std::string::size_type
int lastPos=0, startOfDatePos = 0, endOfDatePos = 0;
int64_t dateIntValue = 0L;
// TODO: make magical 39 to be dateFieldIndex in future refinement
while (x<43 && inputFile.good() ) {
lastPos = (int)line.find(',', lastPos+1);
if (x== (dateFieldIdx)) // date we seek is in the 41st field
{
startOfDatePos = lastPos+2;
} else if (startOfDatePos != 0)
{
endOfDatePos = (int)line.find(',', startOfDatePos)-1; // ", is end of field, so -1 for " part
break;
}
x++;
}
submittedDateTimeStr = line.substr(startOfDatePos, endOfDatePos-startOfDatePos ); ///19);
// truncate the hours, minutes and seconds off of the date
submittedDateStr = submittedDateTimeStr.substr(0, submittedDateTimeStr.length()-9 );
while(submittedDateStr.find('-') != std::string::npos )
submittedDateStr = submittedDateStr.erase( submittedDateStr.find('-'), 1);
dateIntValue = std::atol(submittedDateStr.c_str());//, std::locale("en_US.utf-8"));
if (dateIntValue <= bottomCutOffDateValue || dateIntValue >= topCutOffDateValue)
continue; // skip to the next record if this one is too early or too late
if (outputFile.is_open())
outputFile << line << endl;
else
exit(EXIT_FAILURE);
}
inputFile.close();
outputFile.close();
}
return 0;
}
This is schema diagram appears in the Donors Choose web site to serve as a diagram for the recomposition of the csv files: back to top